package TakeawayItems;

import java.sql.SQLOutput;
import java.util.ArrayList;
import java.util.Scanner;

public class FoodOperation {
    //上架商品
    ArrayList<Food> foodArrayList = new ArrayList<>();

    //Scanner scanner = new Scanner(System.in);
    public void foodAdd(){
        Food f = new Food();

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入菜品名字：");
        String name = scanner.next();
        f.setName(name);

        System.out.println("请输入该菜品的价格：");
        double price = scanner.nextDouble();
        f.setPrice(price);

        System.out.println("请输入菜品的细节：");
        String desc = scanner.next();
        f.setDesc(desc);

        System.out.println("上架成功");
        foodArrayList.add(f);
    }

    //展示菜品
    public void display(){
        if (foodArrayList.size() == 0){
            System.out.println("先去上架");
            return;
        }
        System.out.println("--------------------");
        for (int i = 0; i < foodArrayList.size(); i++) {
            System.out.println(foodArrayList.get(i).getName());
            System.out.println(foodArrayList.get(i).getPrice());
            System.out.println(foodArrayList.get(i).getDesc());
        }
        System.out.println("--------------------");
    }
    //开始界面
    public void startScreen(){
        while (true){
            System.out.println("选择：1.上架商品  2.展示商品  3.退出");
            Scanner scanner = new Scanner(System.in);
            String str = scanner.nextLine();
            switch (str){
                case "1":
                    foodAdd();
                    break;
                case "2":
                    display();
                    break;
                case "3":
                    System.out.println("退出程序");
                    return;
                default:
                    System.out.println("不符合规则，请重新输入：");
            }
        }
    }
}
